﻿/*
 *  XTL - XNA Tool Library, a collection with useful XNA classes
 * 
 *  Copyright (C) 2009 Sebastian Schäfer
 *  Copyright (C) 2009 Frank Nagl, www.franknagl.de
 * 
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License 
 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
namespace XTL.ImageProcessing
{
    using RgbColor = System.Drawing.Color;
    using XnaColor = Microsoft.Xna.Framework.Graphics.Color;

    /// <summary>
    /// Converts rgb colors (System.Drawing.Color) to XNA 
    /// colors (Microsoft.Xna.Framework.Graphics.Color) and back.
    /// </summary>
    public struct ColorConverter
    {
        /// <summary>
        /// Converts a XNA color to RGB color.
        /// </summary>
        /// <param name="xnaColor">XNA color to convert.</param>
        /// <returns>The created rgb color.</returns>
        public static RgbColor XnaToRgbColor(XnaColor xnaColor)
        {
            return RgbColor.FromArgb(xnaColor.A,
                                     xnaColor.R,
                                     xnaColor.G,
                                     xnaColor.B);
        }

        /// <summary>
        /// Converts a XNA color to RGB color.
        /// </summary>
        /// <param name="rgbColor">RGB color to convert.</param>
        /// <returns>The created XNA color.</returns>
        public static XnaColor RgbToXnaColor(RgbColor rgbColor)
        {
            return new XnaColor(rgbColor.R,
                                rgbColor.G,
                                rgbColor.B,
                                rgbColor.A);
        }
    }
}
